<style type="text/css">
	#panel-preview, #code-preview{
		width:600px; 
		height:300px;
	}
</style>
<div class="panel-base panel-admin">
	<div>			
	<?php if (!empty($item['BAN_CODE'])): ?>		
		<form id="frm-code" action="<?php print base_url(); ?>admin/banner/view/submit-c" method="post" enctype="multipart/form-data">
			<input type="hidden" name="did" value="<?php print $item['BAN_ID']; ?>" />						
			<div class="control-group row-fluid" id="group-anp">									
				<span class="span2">Code</span>	
				<div class="span8">
					<div class="controls">
						<textarea name="cb" id="cb" rows="2" style="resize:none; width:300px;"><?php print $item['BAN_CODE']; ?></textarea>
					</div>													
				</div>				
			</div>
			<div class="control-group row-fluid" id="group-anp">									
				<span class="span2">ตำแหน่ง</span>	
				<div class="span8">
					<div class="controls">
						<?php print form_dropdown('dt', $banner_position, $item['BAN_P_ID'], 'id="dt"')?>
					</div>													
				</div>				
			</div>
			<div class="control-group row-fluid" id="group-anp">									
				<span class="span2">วันที่เริ่ม</span>	
				<div class="span8">
					<div class="controls">
						<input type="text" class="dtpicker span4" name="dps" value="<?php print date('Y-m-d', strtotime($item['BAN_S_DATETIME'])); ?>" />
					</div>													
				</div>				
			</div>
			<div class="control-group row-fluid" id="group-anp">									
				<span class="span2">วันที่สิ้นสุด</span>	
				<div class="span8">
					<div class="controls">
						<input type="text" class="dtpicker span4" name="dpe" value="<?php print date('Y-m-d', strtotime($item['BAN_E_DATETIME'])); ?>" />
					</div>													
				</div>				
			</div>
			<div class="control-group row-fluid" id="group-anp">									
				<span class="span2">จำนวนวันที่</span>	
				<div class="span8">
					<div class="controls">
						<span id="d-remain"><?php print ceil((strtotime($item['BAN_E_DATETIME']) - strtotime($item['BAN_S_DATETIME'])) / 86400); ?> วัน</span>
					</div>													
				</div>				
			</div>			
			<div>
				<button class="btn btn-primary">บันทึกข้อมูล</button>
				<a role="button" class="btn" href="<?php print base_url(); ?>admin/banner">ยกเลิก</a>
			</div>					
		</form>	
	<?php else: ?>
		<div class="panel-preview">			
			<img src="<?php print $item['BAN_IMG']; ?>" style="width:<?php print $item['BAN_WIDTH']; ?>px; height:<?php print $item['BAN_HEIGHT']; ?>px;" />							
		</div>
		<div class="panel-space"></div>
		<form id="frm-upload" action="<?php print base_url(); ?>admin/banner/view/submit-u" method="post" enctype="multipart/form-data">
			<input type="hidden" name="did" value="<?php print $item['BAN_ID']; ?>" />
			<div class="control-group row-fluid" id="group-anp">
				<span class="span2">สถานะใช้งาน</span>
				<div class="span8">
					<div class="switch switch-small switch-state" data-on="success" data-off="danger">
					<?php if ($item['BAN_STATE']): ?>
						<input type="checkbox" name="ds" checked="checked" />
					<?php else: ?>
						<input type="checkbox" name="ds"  />
					<?php endif; ?>											
					</div>
				</div>
			</div>				
			<div class="control-group row-fluid" id="group-anp">									
				<span class="span2">ขนาดรูป</span>	
				<div class="span8">
					<div class="controls">
						<input type="text" name="dwidth" class="input-mini" value="<?php print $item['BAN_WIDTH']; ?>" /> x
						<input type="text" name="dheight" class="input-mini" value="<?php print $item['BAN_HEIGHT']; ?>" /> pixel
					</div>													
				</div>				
			</div>
			<div class="control-group row-fluid" id="group-anp">									
				<span class="span2">URL</span>	
				<div class="span8">
					<div class="controls">
						<input type="text" name="durl" class="input-large" value="<?php print $item['BAN_URL']; ?>" placeholder="http://www.example.com" />
					</div>													
				</div>				
			</div>
			<div class="control-group row-fluid" id="group-anp">									
				<span class="span2">ตำแหน่ง</span>	
				<div class="span8">
					<div class="controls">
						<?php print form_dropdown('dt', $banner_position, $item['BAN_P_ID'], 'id="dt"')?>
					</div>													
				</div>				
			</div>
			<div class="control-group row-fluid" id="group-anp">									
				<span class="span2">วันที่เริ่ม</span>	
				<div class="span8">
					<div class="controls">
						<input type="text" class="dtpicker span4" name="dps" value="<?php print date('Y-m-d', strtotime($item['BAN_S_DATETIME'])); ?>" />
					</div>													
				</div>				
			</div>
			<div class="control-group row-fluid" id="group-anp">									
				<span class="span2">วันที่สิ้นสุด</span>	
				<div class="span8">
					<div class="controls">
						<input type="text" class="dtpicker span4" value="<?php print date('Y-m-d', strtotime($item['BAN_E_DATETIME'])); ?>" name="dpe" />
					</div>													
				</div>				
			</div>
			<div class="control-group row-fluid" id="group-anp">									
				<span class="span2">คงเหลือ</span>	
				<div class="span8">
					<div class="controls">
						<span id="d-remain"><?php print ceil((strtotime($item['BAN_E_DATETIME']) - strtotime($item['BAN_S_DATETIME'])) / 86400); ?> วัน</span>
					</div>													
				</div>				
			</div>
			<div>									
				<button class="btn btn-primary">บันทึกข้อมูล</button>
				<a role="button" class="btn" href="<?php print base_url(); ?>admin/banner">ยกเลิก</a>					
			</div>	
		</form>	
	<?php endif; ?>	
		
	</div>	
</div>

<script type="text/javascript">
	$(function(){		
		$('#btn-change-date-submit').click(function(){
			$('#frm-change-date').submit();
		});
		$('.dtpicker').datepicker({
			dateFormat	: 'yy-mm-dd'
		});
	});
</script>

